#include <bits/stdc++.h>
using namespace std;
int   w[200002];
int sum[200002];
int f[200002];
int main(){
    int n,a;
    cin >> n>> a;
    for (int i = 1; i <= n; i++){
        cin >> w[i];
    }
    for (int i = 1; i <= n; i++){
        sum[i]=sum[i-1]+w[i];
    }
    for (int i = 1; i <= n; i++){
        //单独一行
        f[i] = f[i-1]+ w[i]*w[i];
        int x=sum[i]-sum[i-2];
        f[i-2] + x*x - 2*a*x + a*a;
    }
    return 0;
}